import request from '@/utils/request'

// 获取文章频道
export const getChannels = () => {
  return request({
    method: 'GET',
    url: '/mp/v1_0/channels'
  })
}

// 获取文章列表
export const getArticles = params => {
  return request({
    method: 'GET',
    url: "/mp/v1_0/articles",
    params
  })
}

// 删除文章
export const deleteArticle = target => {
  return request({
    method: 'DELETE',
    url: `/mp/v1_0/articles/${target}`
  })
}

// 发表文章
export const publishArticle = (data, draft = false) => {
  return request({
    method: 'POST',
    url: '/mp/v1_0/articles',
    data,
    params: {
      draft
    }
  })
}

// 获取指定文章详情
export const getArticleDetail = target => {
  return request({
    method: "GET",
    url: `/mp/v1_0/articles/${target}`
  })
}
